import request from 'umi-request';

const API_KEY = 'antd';
// const BASE_URL = 'https://public-api-v2.aspirantzhang.com/api/admins';
const BASE_URL = '/api/admins'; // 本地接口路径

export async function fetchAdminList(params: any) {
    return request(`${BASE_URL}?X-API-KEY=${API_KEY}`, {
        method: 'GET',
        params,
    });
}

export async function deleteAdmin(id: number | number[]) {
    return request(`${BASE_URL}/delete?X-API-KEY=${API_KEY}`, {
        method: 'POST',
        data: {
            id: Array.isArray(id) ? id : [id],
        },
    });
}

export async function createAdmin(data: any) {
    return request(`${BASE_URL}/add?X-API-KEY=${API_KEY}`, {
        method: 'POST',
        data,
    });
}

export async function updateAdmin(id: number, data: any) {
    return request(`${BASE_URL}/${id}?X-API-KEY=${API_KEY}`, {
        method: 'PUT',
        data,
    });
}